﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using yncTech.Common;

public partial class Admin_AdminLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txtUserName.Value = WebHelper.GetCookie("yncTech.LoginNo");

            //txtUserName.Value = "admin";
            //password.Value = "123";

            //btn_Login_Click(null, null);
        }
    }

    protected void btn_Login_Click(object sender, EventArgs e)
    {
        try
        {
            lbError.Text = "";
            LoginUserInfo.Login(txtUserName.Value, password.Value);
            Response.Redirect("/Admin/Home.aspx", true);
        }
        catch (BusinessException bex)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('" + bex.ExceptionMessage + "');", true);
            
            //lbError.Text = bex.ExceptionMessage;
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('" + ex.Message + "');", true);
            //lbError.Text = ex.Message;
        }
    }
}